<template>
  <div class="content">
    <el-row>
      <el-col :span="8">
        <el-input placeholder="请输入" v-model="keyword" class="input-with-select">
          <el-select v-model="select" style="width: 120px;" slot="prepend" placeholder="请选择">
            <el-option label="快递单号" value="KDnumber"></el-option>
            <el-option label="vipid" value="vipid"></el-option>
          </el-select>
          <el-button slot="append" icon="el-icon-search" @click="search"></el-button>
        </el-input>
      </el-col>
    </el-row>
    <div class="table">
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column prop="LineType" label="快递类型" align="center"></el-table-column>
        <el-table-column prop="mobile" label="联系电话" align="center"></el-table-column>
        <el-table-column label="详细地址" align="center">
          <template slot-scope="scope">
            {{ scope.row.area + scope.row.DetailedAddress }}
          </template>
        </el-table-column>
        <el-table-column prop="status" label="状态" align="center"></el-table-column>
        <el-table-column prop="status" label="物流信息" align="center">
          <template slot-scope="scope">
            <el-button @click="lookWuliu(scope.row)" type="text" size="small">查看物流信息</el-button>
          </template>
        </el-table-column>
        <el-table-column fixed="right" v-if="$_permissions() == '2' || $_permissions() == '3'" label="操作" width="150" align="center">
          <template slot-scope="scope">
            <el-button @click="handleTable(scope.row)" type="text" size="small">查看</el-button>
            <el-button @click="handleClick(scope.row, false)" type="text" size="small" v-if="$_permissions() == '3'">删除</el-button>
            <!-- <el-button @click="handleClick(scope.row, true)" type="text" size="small">编辑</el-button> -->
          </template>
        </el-table-column>
      </el-table>
    </div>
    <el-dialog title="查看" :visible.sync="showTable" width="60%"><order-table :data="data"></order-table></el-dialog>
    <el-dialog title="物流信息" :visible.sync="showWuliu" width="30%">
      <div class="wuliu_item" v-for="(item, index) in wuliu" :key="index" :class="{active:index == 0}">
        <div class="news" v-if="index == 0">最新</div>
        <div class="date">{{item.ftime}}</div>
        <div class="context">{{item.context}}</div>
      </div>
      <!-- <el-steps direction="vertical" :active="0" :space="60">
        <el-step v-for="(item, index) in wuliu" :key="index" :title="item.ftime" :description="item.context"></el-step>
      </el-steps> -->
    </el-dialog>
  </div>
</template>

<script>
import { searchOutOrder } from '@/api/test.js';
import orderTable from '@/components/table/index.vue';
export default {
  name: 'hongcaitj',
  components: {
    orderTable
  },
  data() {
    return {
      tableData: [],
      showTable: false,
      showWuliu: false,
      keyword: 'CI197357759JP', //搜索的订单号
      data: null,
      select: 'KDnumber',
      wuliu: []
    };
  },
  methods: {
    lookWuliu(row) {
      var data = JSON.parse(row.wuliuInfo);
      console.log(data);
      this.wuliu = data;
      this.showWuliu = true;
    },
    handleTable(row) {
      this.data = row;
      this.showTable = true;
    },
    handleClick(row, status) {
      //status true:编辑 false:删除
      if (status) {
        //编辑
        this.ruleForm = { ...row };
        //this.show = true;
      } else {
        this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
          .then(() => {
            delZYorder({ id: row.id, vipid: row.vipid }).then(res => {
              if (res.msg.indexOf('成功') != -1) {
                this.$message.success(res.msg);
                this.getList();
              } else {
                this.$message.error(res.msg);
              }
            });
          })
          .catch(() => {});
      }
    },
    search() {
      //搜索订单号
      if (this.keyword == '') {
        return this.$message.error('搜索内容不能为空！');
      }
      var obj = {};
      obj[this.select] = this.keyword;
      searchOutOrder(obj).then(res => {
        console.log(res);
        this.tableData = res;
      });
    }
  },
  mounted() {}
};
</script>

<style lang="scss" scoped>
.content {
  .wuliu_item{
    color: #333;
    padding-left: 90px;
    position: relative;
    margin-top: 15px;
    &::after{
      content: "";
      position: absolute;
      width: 8px;
      height: 8px;
      background-color: #999;
      border-radius: 50%;
      left: 20px;
      top: 5px;
      box-shadow: 0 0 0 10px #fff;
    }
    &::before{
      content: "";
      position: absolute;
      width: 1px;
      height: calc(100% + 30px);
      background-color: #ddd;
      left: 24px;
      top: 0;
    }
    &.active{
      color: red;
      font-weight: 600;
    }
    .news{
      position: absolute;
      left: 40px;
      top: 0;
      padding: 2px 5px;
      background-color: red;
      border-radius: 2px;
      color: #fff;
    }
    .date{

    }
    .context{
      padding: 10px 0 15px;
    }
  }
}
</style>
